$(function() {
    var atHome = $('#home-badge-contact').length;
    //resize all the components of the page
    function resize(){
        var screen_height = $(window).height();
        var header_height = $("#header-wrapper").height();
        var h = 0.96*(screen_height-header_height);
        $("#dialog-pane").height(h);
        $("#userlist-pane-wrapper").height(h);
        $("#remote-user").height(35);
        var textpane_height = 0.99*($("#dialog-pane").height()-$("#textfield").height()-$("#remote-user").height()-60);
        $("#message-pane").height(textpane_height);
        
        $("#userlist").height(0.32* h);
        $("#group-list").height(0.24* h);
        $("#search-contact").height(0.09*h);
        $("#search-group").height(0.09*h);
        $("#userlist-pane").height(0.95*h);
        //$("#avatar-wrapper").height();
        $( "#status" ).position({
            my: "center center",
            at: "center+20 center",
            collision:"flip",
            of: "#username-wrapper"
        });
        if(!atHome){
            $( "#contact-requests-wrapper" ).position({
                my: "center center",
                at: "right top-14",
                collision:"fit",
                of: "#param-wrapper"
            });
            
            $( "#contact-requests" ).position({
                my: "center center",
                at: "center+15 center-12",
                collision:"flip",
                of: "#notifs-img"
            });
            
        }
        
        //for home page only
        if (atHome) {
            $( "#home-badge-msg" ).position({
                my: "center center",
                at: "center-34 center-16 ",
                collision:"fit",
                of: "#messages-recvd-notifs"
            });
            $( "#home-badge-contact" ).position({
                my: "center center",
                at: "center-34 center-16 ",
                collision:"fit",
                of: "#contacts-req-notifs"
            });
            $( "#home-badge-group" ).position({
                my: "center center",
                at: "center-34 center-16",
                collision:"fit",
                of: "#group-req-notifs"
            });
        }    
    }
    
    resize();
    $('#textfield').hide();
    $('#remote-user').hide();
    $( document ).tooltip();
}) ;